package com.noble.glamour.bean.center.user.detail;

import android.os.Parcel;
import android.os.Parcelable;

import com.noble.library.base.bean.BaseData;

import org.json.JSONObject;

/**
 * 用户信息基类
 */
public class UserBasic extends BaseData implements Parcelable {
    public long uid;             // 用户Id
    private String avatar;       // 头像
    private String avatarStatus; // 头像状态    -3：未上传 -2：审核中 -1：未通过 1：通过
    private String nickname;     // 昵称
    private int gender;          // 性别 -1：未填  1：男  2：女

    @Override
    public void parseJson(String s) {
        JSONObject detailObject = getJsonObject(s);
        this.setUid(detailObject.optLong("Uid"));
        this.setAvatar(detailObject.optString("Avatar"));
        this.setAvatarStatus(detailObject.optString("StatusAvatar"));
        this.setNickname(detailObject.optString("NickName"));
        this.setGender(detailObject.optInt("Gender"));
    }

    /**
     * 判断用户是否为男性
     *
     * @return true 男性
     */
    public boolean isMan() {
        return getGender() == 1;
    }

    /**
     * @return 是否未完善性别
     */
    public boolean noGender() {
        return getGender() <= 0;
    }

    public String getAvatarStatus() {
        return avatarStatus;
    }

    public void setAvatarStatus(String avatarStatus) {
        this.avatarStatus = avatarStatus;
    }

    public int getGender() {
        return gender;
    }

    public void setGender(int gender) {
        this.gender = gender;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public long getUid() {
        return uid;
    }

    public void setUid(long uid) {
        this.uid = uid;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public UserBasic() {
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(this.uid);
        dest.writeString(this.avatar);
        dest.writeString(this.avatarStatus);
        dest.writeString(this.nickname);
        dest.writeInt(this.gender);
    }

    protected UserBasic(Parcel in) {
        this.uid = in.readLong();
        this.avatar = in.readString();
        this.avatarStatus = in.readString();
        this.nickname = in.readString();
        this.gender = in.readInt();
    }

    public static final Creator<UserBasic> CREATOR = new Creator<UserBasic>() {
        @Override
        public UserBasic createFromParcel(Parcel source) {
            return new UserBasic(source);
        }

        @Override
        public UserBasic[] newArray(int size) {
            return new UserBasic[size];
        }
    };
}
